<?php 
	if( $this->level >= 1 && $this->level <= 6 )
	{
		/*trainlX*/
		$baseUrl = $this->baseUrl('images/buildings/trainl'.$this->level.'.jpg');
		echo '<span class="building-title">TRAIN UNITS</span>';
		echo '<img src="'.$baseUrl.'"></img>';

		if( $this->trainRestrictLvl == -1 )
		{
			echo $this->trainRestrict;
		}
		else 
		{
			$explodeString = explode(".", $this->trainStory);
			foreach( $explodeString as $storyPhrase )
			{
				if( $storyPhrase != "" ){
				echo '<span>';
				echo $storyPhrase;
				echo '</span>';
				}
			}
			echo '<div class="building-requirements">';
			echo '<span class="building-title">Units Training Details:</span>';
			echo '<span>You have: '.$this->lvl1Untrained.' untrained level 1 units!</span>';
			if ($this->trainRestrict != "0")
			{
				$urlArray = array('controller' =>'buildings', 'action'=>'build');
				$building_nameUrl = str_replace(" ", "", $this->trainRestrict); 
				echo '<span>You need to build <a class="kingdom-building" href="'.$this->url($urlArray).'?v='.$building_nameUrl.'">'.ucfirst($this->trainRestrict).'</a>'.' level '.$this->trainRestrictLvl.'</span>'; 
			}

			if ($this->trainRestrictPopulation != "0")
			{
				$urlArray = array('controller' =>'buildings', 'action'=>'build');
				echo '<span>'.$this->trainRestrictPopulation.'(<a class="kingdom-building" href="'.$this->url($urlArray).'?v=farms">Farms</a>)</span>'; 
			}
			echo '<span>Cost: '. (int)$this->trainCost.' coins<br/>Power earned after training: '. $this->trainPower. '</span>';
			echo $this->buildingTrain;
			
			if( isset($this->trainValidationError) )
				echo $this->trainValidationError;
			}
			echo '</div>';
	}
?>

<hr />

<?php 
	if( $this->level >= 1 && $this->level <= 6 )
	{
		echo '<span class="building-title">HIRE UNITS</span>';
		/*hireX*/
		$baseUrl = $this->baseUrl('images/buildings/unit'.$this->level.'.jpg');
		echo '<img src="'.$baseUrl.'"></img>';
		$explodeString = explode(".", $this->hireStory);
		foreach( $explodeString as $storyPhrase )
		{
			if( $storyPhrase != "" ){
				echo '<span>';
				echo $storyPhrase;
				echo '</span>';
			}
		}
		echo '<div class="building-requirements">';
		echo '<span class="building-title">Units Hiring Details:</span>';
		echo '<span>You can hire: '. $this->hireSpaceAvailable.' units!</span>';
		if ($this->hireRestrict != "0")
		{
			$urlArray = array('controller' =>'buildings', 'action'=>'actions');
			$building_nameUrl = str_replace(" ", "", $this->hireRestrict); 
			echo '<span>You need to build <a class="kingdom-building" href="'.$this->url($urlArray).'?v='.$building_nameUrl.'">'.ucfirst($this->hireRestrict).'</a>'.' level '.$this->hireRestrictLvl.'</span>'; 
		}
		if ($this->hireRestrictPopulation != "0")
		{
			$urlArray = array('controller' =>'buildings', 'action'=>'actions');
			echo '<span>'.$this->hireRestrictPopulation .' <a class="kingdom-building" href="'.$this->url($urlArray).'?v=farms">Farms</a></span>'; 
		}
		echo '<span>This type of unit provides:</span><span>Cost: '. (int)$this->hireCost.' coins<br/>Power: '. $this->hirePower. '</span>';
		echo $this->buildingHire;
		echo '</div>';
	}


	$urlArrayBack = array('controller' =>'kingdom', 'action'=>'list');
	echo '<a class="back-action" href="'.$this->url($urlArrayBack, null, true).'">&larr;&nbsp;Back To Kingdom</a>' ;
